//
// Created by yyancy on 2019/12/24.
//
#include <vector>
#include <istream>

void copy(int *f1, int *e1, int *f2) {
    int *t1 = f1, *t2 = f2;
    while (t1 != e1) {
        *t2 = *t1;
        t2++;
    }
}

template<typename Elem>
struct Link {
    Link *prev;
    Link *succ;
    Elem val;
};

template<typename Elem>
class list {
public:
    class iterator;

    iterator begin();

    iterator end();

    iterator insert(iterator p, const Elem &v);

    iterator erase(iterator p);

    void push_back(const Elem &v);

    void push_front(const Elem &v);

    void pop_front();

    void pop_back();

    Elem &front();

    Elem &back();
};

template<typename Elem>
class list<Elem>::iterator {
    Link<Elem> *curr;
public:
    iterator(Link<Elem> *p) : curr{p} {}

    iterator &operator++() {
        curr = curr->succ;
        return *this;
    }

    iterator &operator--() {
        curr = curr->prev;
        return *this;
    }

    Elem &operator*() {
        return curr->val;
    }

    bool operator==(const iterator &b) {
        return curr == b.curr;
    }

    bool operator!=(const iterator &b) {
        return curr != b.curr;
    }


};


using namespace std;
using Line = vector<char>;

struct Document {
    list<Line> line;

    Document() { line.push_back(Line{}); }
};

istream &operator>>(istream &is, Document &d) {
    for (char ch; is.get(ch);) {
        d.line.back().push_back(ch);
        if (ch == '\n')
            d.line.push_back(Line{});
    }
    if (d.line.back().size())d.line.push_back(Line{});
    return is;
}
